import Vue from 'vue';
import App from './App.vue';

import './element-ui';

import VueQrcode from '@chenfengyuan/vue-qrcode';
Vue.component(VueQrcode.name, VueQrcode);

import VueClipboard from 'vue-clipboard2';
Vue.use(VueClipboard);

import VueQriously from 'vue-qriously';
Vue.use(VueQriously);

import router from './routers/index';
import store from './vuex/index';
import _api from './fetch/api.js';

import _ from './assets/js/utils.js';

function getCurWsOrigin() {
	let location = window.location;
	if (location.protocol === 'https:') {
		return `wss://${location.host}/zbcloud-ws`;
	} else if (location.protocol === 'http:') {
		return `ws://${location.host}/zbcloud-ws`;
	}
}

window.API = _api;

window.YDT_CLOUD_URI = getCurWsOrigin();

window._ = _;

if (!window.sessionStorage.getItem('_s')) {
	const sessionId = Math.random()
		.toString(36)
		.substr(2);
	window.sessionStorage.setItem('_s', sessionId);
}

if (window.sessionStorage.getItem('_LogoObj')) {
	let LogoObj = JSON.parse(window.sessionStorage.getItem('_LogoObj'));
	store.state.logoObj = LogoObj;
}

//CSS
import './assets/less/ionicons.min.css';
import './assets/less/main.less';
import './assets/less/base/button.less';
import './assets/less/theme.less';
import './assets/less/elementStyle.less';

//filters
import './filters/index';

//main element theme
import '../theme/element-variables.scss';

Vue.config.productionTip = false;

new Vue({
	router,
	store,
	data: {
		eventBus: new Vue()
	},
	render: h => h(App)
}).$mount('#app');
